var wailianStaticMethod = function(url,key,params,pushstatus,backstatus) {  
    var obj = new Object();
    var userAgent = navigator.userAgent.toLowerCase();
    obj.getSystem = function(){
        if (userAgent.search("windows nt") != -1) {
            pvendor = 4;
        } else if (userAgent.search("iphone") != -1) {
            pvendor = 2;
        } else if (userAgent.search("ipad") != -1) {
            pvendor = 3;
        } else if (userAgent.search("android") != -1) {
            pvendor = 1;
        } else if (userAgent.search("macintosh") != -1) {
            pvendor = 5;
        } else {
            pvendor = 0;
        }
        return pvendor;
    }
    obj.getBrowser = function() {
        // 判断访问是什么设备
        if (userAgent.search('micromessenger') != -1) {
            // 微信浏览器
            browser = "1";
        } else if(userAgent.search('qqbrowser') != -1){
            // 电脑QQ浏览器
            browser = "2";
        } else if(userAgent.search('vivobrowser') != -1){
            // Vivo浏览器
            browser = "3";
        } else if(userAgent.search('heytapbrowser') != -1){
            // Oppo浏览器
            browser = "4";
        } else if(userAgent.search('huaweibrowser') != -1){
            // 华为浏览器
            browser = "5";
        } else if(userAgent.search('miuibrowser') != -1){
            // 小米浏览器
            browser = "6";
        } else if(userAgent.search('mqqbrowser') != -1){
            // QQ浏览器
            browser = "7";
        } else if(userAgent.search('alipayclient') != -1){
            // 支付宝浏览器
            browser = "8";
        } else if(userAgent.search('baiduboxapp') != -1){
            // 百度APP
            browser = "9";
        } else if(userAgent.search('weibo') != -1){
            // 微博浏览器
            browser = "10";
        } else if(userAgent.search('iqiyi') != -1){
            // 爱奇艺浏览器
            browser = "11";
        } else if(userAgent.search('miuibrowser') != -1 || userAgent.search('xiaomi') != -1){
            // 小米浏览器
            browser = "12";
        } else if(userAgent.search('bytelocale') != -1 || userAgent.search('bytedancewebview') != -1){
            // 抖音浏览器
            browser = "26";
        } else if(userAgent.search('kdtunion_iting') != -1){
            // 喜马拉雅
            browser = "13";
        } else if(userAgent.search('dingtalk') != -1){
            // 钉钉
            browser = "14";
        } else if(userAgent.search('ucbrowser') != -1){
            // UC浏览器
            browser = "15";
        } else if(userAgent.search('samsungbrowser') != -1){
            // 三星浏览器
            browser = "16";
        } else if(userAgent.search('nokiabrowser') != -1){
            // 诺基亚浏览器
            browser = "17";
        } else if(userAgent.search('opera') != -1){
            // 欧朋
            browser = "18";
        } else if(userAgent.search('firefox') != -1){
            // 火狐
            browser = "19";
        } else if(userAgent.search('zhihu') != -1 || userAgent.search('hihu') != -1){
            // 知乎
            browser = "20";
        } else if(userAgent.search('larkLocale') != -1){
            browser = "21";
        } else if(userAgent.search('iphone') != -1){
            browser = "22";
        } else if(userAgent.search('ipad') != -1){
            browser = "23";
        } else if(userAgent.search('macintosh') != -1){
            browser = "24";
        } else {
            browser = "25";
        }
        return browser;
    }
    obj.getDevice = function(){
        var sUserAgent = navigator.userAgent.toLowerCase();
        var isIphone = userAgent.match(/iphone/i) == "iphone";
        var isHuawei = userAgent.match(/huawei/i) == "huawei";
        var isHonor = userAgent.match(/honor/i) == "honor";
        var isOppo = userAgent.match(/oppo/i) == "oppo";
        var isRealme = userAgent.match(/rmx/i) == "rmx";
        var isOppoR15 = userAgent.match(/pacm00/i) == "pacm00";
        var isVivo = userAgent.match(/vivo/i) == "vivo";
        var isXiaomi = userAgent.match(/mi\s/i) == "mi ";
        var isXiaomi2s = userAgent.match(/mix\s/i) == "mix ";
        var isRedmi = userAgent.match(/redmi/i) == "redmi";
        var isSamsung = userAgent.match(/sm-/i) == "sm-";
        if (isIphone) {
            return 6;
        } else if (isHuawei || isHonor) {
            return 1;
        } else if (isOppo || isOppoR15 || isRealme) {
            return 4;
        } else if (isVivo) {
            return 2;
        } else if (isXiaomi || isRedmi || isXiaomi2s) {
            return 3;
        } else if (isSamsung) {
            return 5;
        } else {
            return 0;
        }
    }
    obj.backJson = function(deviceInfo) {
        const requestparams = Object.assign(params, deviceInfo);
        wailianStaticBack(requestparams);
    }
    obj.pushApiInfo = function(deviceInfo){
        var urlscheme_time = Math.round(new Date().getTime()/1000).toString();
        var usersview = localStorage.getItem("ttwlstatic_"+key) || "";
        var review = 1;
        if (usersview == ""){
            // 未访问,执行推送
            localStorage.setItem("ttwlstatic_"+key,key);
        } else {
            return;
        }
        const requestparams = Object.assign(params, deviceInfo);
        requestparams["links_id"] = key;
        requestparams["sorts"] = 1;
        $.ajax({
            "type":"POST",
            "url": url,
            "data":requestparams,
            success:(res)=>{}
        });
        return "success";
    }
    obj.inviteCode = function() {
        var name = "channel";
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        var code = "";
        if (r != null) code = unescape(r[2]);
        if (code.length > 10) return "";
        return code;
    }
    obj.device = function() {
        const system = this.getSystem();
        const browser = this.getBrowser();
        const device = this.getDevice();
        const code = this.inviteCode();
        if (backstatus) {
            this.backJson({"system": system, "browser": browser, "device": device, "code": code});
        }
        if (pushstatus) {
            this.pushApiInfo({"system": system, "browser": browser, "device": device, "code": code});
        }
    }
    return obj;  
}